export const daysOfWeek = [
    ['星期日', '日'],
    ['星期一', '一'],
    ['星期二', '二'],
    ['星期三', '三'],
    ['星期四', '四'],
    ['星期五', '五'],
    ['星期六', '六']
];

export const monthsOfYear = [
    ['一月', 'Jan'],
    ['二月', 'Feb'],
    ['三月', 'Mar'],
    ['四月', 'Apr'],
    ['五月', 'May'],
    ['六月', 'Jun'],
    ['七月', 'Jul'],
    ['八月', 'Aug'],
    ['九月', 'Sep'],
    ['十月', 'Oct'],
    ['十一月', 'Nov'],
    ['十二月', 'Dec']
];

export function formatDate(date: Date, fmt: string) {
    const lookup: Record<string, any> = {
        "y+": date.getFullYear(),//年
        "M+": date.getMonth() + 1, //月份
        "d+": date.getDate(), //日
        "h+": date.getHours(), //小时
        "m+": date.getMinutes(), //分
        "s+": date.getSeconds(), //秒
        "q+": Math.floor((date.getMonth() + 3) / 3), //季度
        "S+": date.getMilliseconds(), //毫秒
    };
    for (let key in lookup) {
        let rea = fmt.match(new RegExp("(" + key + ")"));
        if (rea) {
            const val = "" + lookup[key];
            const find = rea[1];
            let replaceWith = (key === "y+") ? val.slice(4 - find.length) :
                (key === "S+" ? val : ("00" + val).slice(val.length));
            fmt = fmt.replace(find, replaceWith);
        }
    }
    return fmt;
}
export function datePlusDays(date: Date, days: number): Date {
    return new Date(date.getTime() + days * 24 * 60 * 60 * 1000)
}